local scene = director:createScene()

function scene:setUp(event)
    dbg.print("sceneMenu:setUp")
	
	local allScaleX = 480/director.displayWidth
	local allScaleY = 320/director.displayHeight
	
	if (io.open("scoreTime.txt") == nil) then
	file = io.open("scoreTime.txt", "w")
	file:write("999".."\n")
	file:write("999".."\n")
	file:write("999".."\n")
	file:close()
	end
	
    local buttonGame = director:createSprite(director.displayCenterX, director.displayCenterY, "img/button.png")
	buttonGame.xAnchor=0.5; buttonGame.yAnchor=0.5
	buttonGame.y =  director.displayCenterY + buttonGame.h/3/allScaleY
	buttonGame.yScale=.7/allScaleY; 
	buttonGame.xScale=1.1/allScaleX;
	
	labelGame = director:createLabel(director.displayCenterX, director.displayCenterY, "Play")
	labelGame.xAnchor=0.5; 
	labelGame.zOrder = buttonGame.zOrder
	labelGame. hAlignment="center"
	labelGame.y = buttonGame.y-10/allScaleY
	labelGame.xScale = 1/allScaleX
	labelGame.yScale = 1/allScaleY
	
	local buttonScore = director:createSprite(director.displayCenterX, director.displayCenterY, "img/button.png")
	buttonScore.xAnchor=0.5; buttonScore.yAnchor=0.5
	buttonScore.x = director.displayCenterX - buttonScore.w/1.7/allScaleX
	buttonScore.y = director.displayCenterY - buttonScore.h/2/allScaleY
	buttonScore.yScale=.7/allScaleY; 
	buttonScore.xScale=1.1/allScaleX;
	
	labelScore = director:createLabel(director.displayCenterX, director.displayCenterY, "Score")
	labelScore.xAnchor=0.5; 
	labelScore.zOrder = buttonScore.zOrder
	labelScore. hAlignment="center"
	labelScore.x = buttonScore.x
	labelScore.y = buttonScore.y-10/allScaleY
	labelScore.xScale = 1/allScaleX
	labelScore.yScale = 1/allScaleY
	
	local buttonInstructions = director:createSprite(director.displayCenterX, director.displayCenterY, "img/button.png")
	buttonInstructions.xAnchor=0.5; buttonInstructions.yAnchor=0.5
	buttonInstructions.x = director.displayCenterX + buttonInstructions.w/1.7/allScaleX
	buttonInstructions.y = director.displayCenterY - buttonInstructions.h/2/allScaleY
	buttonInstructions.yScale=.7/allScaleY; 
	buttonInstructions.xScale=1.1/allScaleX;
	
	labelInstructions = director:createLabel(director.displayCenterX, director.displayCenterY, "Instructions")
	labelInstructions.xAnchor=0.5;
	labelInstructions.zOrder = buttonInstructions.zOrder
	labelInstructions. hAlignment="center"
	labelInstructions.x = buttonInstructions.x
	labelInstructions.y = buttonInstructions.y-10/allScaleY
	labelInstructions.xScale = 1/allScaleX
	labelInstructions.yScale = 1/allScaleY
	
	function buttonGame:touch(event)
		if (event.phase == 'began') then
			system:sendEvent("moveToSceneGame")
		end
	end
	buttonGame:addEventListener('touch', buttonGame)

	function buttonInstructions:touch(event)
		if (event.phase == 'began') then
			system:sendEvent("moveToSceneInstructions")
		end
	end
	buttonInstructions:addEventListener('touch', buttonInstructions)
	
	function buttonScore:touch(event)
		if (event.phase == 'began') then
			system:sendEvent("moveToSceneScore")
		end
	end
	buttonScore:addEventListener('touch', buttonScore)
end

function scene:tearDown(event)
    dbg.print("sceneMenu:tearDown")
end

scene:addEventListener({"setUp", "tearDown"}, scene)

return scene